using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using System.IO;
using Microsoft.Xna.Framework;

namespace Scurvy.Media.Pipeline
{
    [ContentProcessor(DisplayName="Streaming Video - Scurvy Media")]
    public class VideoStreamProcessor : ContentProcessor<VideoContent, VideoStreamContent>
    {
        public override VideoStreamContent Process(VideoContent input, ContentProcessorContext context)
        {
            if (input.Count == 0)
            {
                throw new InvalidContentException("No frames where found in the input video");
            }

            GC.Collect();

            Vector2 size = new Vector2(input[0].Faces[0][0].Width, input[0].Faces[0][0].Height);
            int numberOfFrames = input.Count;
            System.Diagnostics.Debug.WriteLine(string.Format("Processing Video Stream"));

            return new VideoStreamContent(
                input,
                //stream,
                numberOfFrames, 
                input.FrameRate, 
                size);
        }
    }
}
